package com.fernfx.xingtan.main.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;
import com.fernfx.xingtan.R;
import com.fernfx.xingtan.common.base.BaseAdapter;
import com.fernfx.xingtan.main.contract.SelectLocationContract;

import java.util.List;

/**
 * Created by admin on 2018/8/23.
 */

public class SelectLocationAdapter extends BaseAdapter {
    private Context context;
    private List<PoiInfo> datas;

    public SelectLocationAdapter(Context context, List datas) {
        super(context, datas);
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_chat_select_location_item;
    }

    @Override
    public Holder initHolder(View container) {
        final SelectLocationHolder selectLocationHolder = new SelectLocationHolder();
        selectLocationHolder.name = container.findViewById(R.id.name);
        selectLocationHolder.location = container.findViewById(R.id.location);
        return selectLocationHolder;
    }

    @Override
    public void initItem(View view, Holder holder, int position) {
        final PoiInfo poiInfo = datas.get(position);
        //convert holder
        SelectLocationHolder selectLocationHolder = (SelectLocationHolder)holder;
        //set value
        selectLocationHolder.name.setText(poiInfo.name);
        selectLocationHolder.location.setText(poiInfo.address);
    }

    /*
     * 控件实体
     */
    public class SelectLocationHolder extends Holder {
        public TextView name;

        public TextView location;
    }
}
